package com.sevennotes.classtable.ui.pages.main_screen

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Info
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import com.sevennotes.classtable.ui.theme.ClassTableTheme
import com.sevennotes.classtable.ui.theme.colorPaletteMaker

@Composable
fun MainScreenPad(
    tittle: @Composable () -> Unit,
    navigationIcon: @Composable (() -> Unit)?,
    floatingActionButton: @Composable () -> Unit = {},
    actions: @Composable RowScope.() -> Unit = {},
    content: @Composable (PaddingValues) -> Unit
) {
    Scaffold(
        topBar = {
            TopAppBar(
                title = tittle,
                navigationIcon = navigationIcon,
                actions = actions,
            )
        },
        contentColor = contentColorFor(backgroundColor = MaterialTheme.colors.background),
        floatingActionButton = floatingActionButton,
        content = content
    )
}

@Preview
@Composable
fun ButtonTest() {
    ClassTableTheme(colors = colorPaletteMaker(Color.White)) {
        Column {
            Button(onClick = { /*TODO*/ }) {
                Text(text = "我是一个按钮")
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
fun MainPadPrev() {
    ClassTableTheme(colors = colorPaletteMaker(Color.White)) {
        Surface {
            MainScreenPad(
                tittle = { Text(text = "课程表")},
                navigationIcon = {
                    IconButton(onClick = { /*TODO*/ }) {
                        Icon(imageVector = Icons.Filled.Info, contentDescription = "Info")
                    }
                },
                actions = {
                    IconButton(onClick = { /*TODO*/ }) {
                        Icon(imageVector = Icons.Filled.Add, contentDescription = "Add")
                    }
                }
            ) {
                Box(modifier = Modifier.fillMaxSize()) {
                    Column {
                        Text(text = "我是测试文字")
                        TextField(value = "我是输入框", onValueChange = {})
                        Button(onClick = { /*TODO*/ }) {
                            Text(text = "我是一个按钮")
                        }
                    }
                }
            }
        }
    }
}

